// pages/detail/detail.js
import api from "../../api/api";
import fetch from "../../api/fetch"
Page({
  // 路不通
  onShareAppMessage() {
    return {
      title: 'swiper',
      path: 'page/component/pages/swiper/swiper'
    }
  },



  changeIndicatorDots() {
    this.setData({
      indicatorDots: !this.data.indicatorDots
    })
  },

  changeAutoplay() {
    this.setData({
      autoplay: !this.data.autoplay
    })
  },

  intervalChange(e) {
    this.setData({
      interval: e.detail.value
    })
  },

  durationChange(e) {
    this.setData({
      duration: e.detail.value
    })
  },

  /**
   * 页面的初始数据
   */
  data: {
    indicatorDots: true,
    vertical: false,
    autoplay: true,
    interval: 2000,
    duration: 500,
    circular: true,
    dataObj: "",
    num: 1,
    iconShow:false,
  },
  onChange(event) {
    console.log(event.detail);
    this.setData({
      num: event.detail
    })
  },
  zhuan(){
wx.navigateTo({
  url: '../order/order?id='+this.data.id,
})
  },
  show() {
   let show=this.data.iconShow
    
    console.log(this.data.iconShow)
    if(this.data.iconShow==false){
      this.setData({
        iconShow:true
      })
      this.animate(".my", [{ bottom: "0rpx" },{bottom:"100rpx"}], 100,()=>{
        console.log("动画走了")
      })
      this.animate(".shopping", [{ bottom: "0rpx" },{ bottom: "200rpx" }], 110)
      this.animate(".all", [{ bottom: "0rpx" },{ bottom: "300rpx" }], 120)
      this.animate(".index", [{ bottom: "0rpx" },{ bottom: "400rpx" }], 130,()=>{
        console.log("动画完成")
      })
    }else{
        this.animate(".my", [{bottom:"100rpx"},{ bottom: "0rpx" }], 100)
      this.animate(".shopping", [{bottom:"200rpx"},{ bottom: "0rpx" }], 110)
      this.animate(".all", [{bottom:"300rpx"},{ bottom: "0rpx" }], 120)
      this.animate(".index", [{bottom:"400rpx"},{ bottom: "0rpx" }], 130,()=>{
        this.setData({
          iconShow:false
        })
      })
    }
   
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    console.log(options.id)
    fetch({ url: api.detail, data: { goods_id: options.id } }).then(data => {
      console.log(data.data.data.detail)
      this.setData({
        dataObj: data.data.data.detail,
        id:options.id
      })
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})